angular.module('wf-utils')
.factory 'IBanner', ($resource,isMock) ->
    mockData = {
        code: 0
        message:
            content: [
                {
                    link: undefined
                    url: "images/nr-offical//home/banner1.jpg"
                    title: "images/nr-offical/home/banner1-title.png"
                }
                {
                    link: undefined
                    url: "images/nr-offical//home/banner2.jpg"
                    title: "images/nr-offical/home/banner2-title.png"
                }
            ]
    }
    $resource '/wainNews', {}, {
        query:
            isArray: true
            transformResponse: (data, header) ->
                data = angular.fromJson data
                if isMock
                    data = mockData
                if data.code == 0 then data.message.content else undefined
        get:
            transformResponse: (data, header) ->
                data = angular.fromJson data
                if isMock
                    data = mockData
                if data.code == 0 then data.message.content else undefined
        update:
            method: 'PUT'
        remove:
            method: 'DELETE'
        new:
            method: 'POST'
    }